<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">

<head>
  <meta charset="UTF-8" />
  <title>会员列表-WeAdmin Frame型后台管理系统-WeAdmin 1.0</title>
  <meta name="renderer" content="webkit" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" />
  <link rel="stylesheet" href="../../../static/css/font.css" />
  <link rel="stylesheet" href="../../../static/css/weadmin.css" />
  <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.5.1.min.js"></script>
  <script>
    $.get({
      url: "/product/list",
      success: function (data) {
        $("#productList").html(data)
      }
    })
  </script>
</head>

<body>
<div class="weadmin-nav">
    <span class="layui-breadcrumb">
      <a href="javascript:;">首页</a> <a href="javascript:;">商品管理</a>
    </span>
  <a class="layui-btn layui-btn-sm" style="margin-top:3px;float:right"
     href="javascript:location.replace(location.href);" title="刷新">
    <i class="layui-icon layui-icon-refresh"></i>
  </a>
</div>

<div class="weadmin-body">
  <div class="layui-row">
    <form class="layui-form layui-col-md12 we-search">
      商品搜索：
      <div class="layui-inline">
        <input class="layui-input start" placeholder="开始日" autocomplete="off" name="start" id="start" />
      </div>
      <div class="layui-inline">
        <input class="layui-input end" placeholder="截止日" autocomplete="off" name="end" id="end" />
      </div>
      <div class="layui-inline">
        <input type="text" name="username" placeholder="请输入商品名" autocomplete="off" class="layui-input username" />
      </div>
      <button class="layui-btn search-btn" lay-submit="" lay-filter="search">
        <i class="layui-icon layui-icon-search"></i>
      </button>
    </form>
  </div>
  <div class="weadmin-block">
    <button class="layui-btn layui-btn-danger" onclick="delAll()">
      <i class="layui-icon layui-icon-delete"></i>批量删除
    </button>
    <button class="layui-btn" onclick="WeAdminShow('添加商品','./add.html',600,400)">
      <i class="layui-icon layui-icon-add-circle-fine"></i>添加
    </button>
    <span class="fr" style="line-height:40px">共有数据：<span>[[${session.productNum}]]</span> 条</span>
  </div>
  <table class="layui-table" id="productList" th:fragment="productList">
    <thead>
    <tr>
      <th>
        <div class="layui-unselect header layui-form-checkbox" lay-skin="primary">
          <i class="layui-icon layui-icon-ok"></i>
        </div>
      </th>
      <th>ID</th>
      <th>商品名称</th>
      <th>商品类型</th>
      <th>商品价格</th>
      <th>发布时间</th>
      <th>状态</th>
      <th>操作</th>
    </tr>
    </thead>
    <tbody  th:each="product : ${session.products}">
    <tr th:data-id="${product.productId}">
      <td>
        <div class="layui-unselect layui-form-checkbox" lay-skin="primary" th:data-id="${product.productId}">
          <i class="layui-icon layui-icon-ok"></i>
        </div>
      </td>
      <td>[[${product.productId}]]</td>
      <td>[[${product.productName}]]</td>
      <td>[[${product.category}]]</td>
      <td>[[${product.price}]]</td>
      <td>[[${product.releaseTime}]]</td>
      <td class="td-status">
        <span th:if="${product.auditing}==1" class="layui-btn layui-btn-normal layui-btn-xs">已启用</span>
        <span th:if="${product.auditing}==0" class="layui-btn layui-btn-normal layui-btn-xs layui-btn-disabled">已停用</span>
      </td>
      <td class="td-manage">
        <a th:if="${product.auditing}==1" onclick="member_stop(this,'10001')" href="javascript:;" title="启用">
          <i class="layui-icon layui-icon-download-circle"></i>
        </a>
        <a th:if="${product.auditing}==0" onclick="member_stop(this,'10001')" href="javascript:;" title="停用">
          <i class="layui-icon layui-icon-upload-circle"></i>
        </a>
        <a title="编辑" onclick="WeAdminEdit('编辑','./edit.html', this, 600, 400)" href="javascript:;">
          <i class="layui-icon layui-icon-edit"></i>
        </a>
        <a title="删除" onclick="member_del(this)" href="javascript:;">
          <i class="layui-icon layui-icon-delete"></i>
        </a>
      </td>
    </tr>
    </tbody>
  </table>
  <div class="page">
    <div class="list" th:fragment="page">
      <span class="num" th:each="page:${session.productPages}" th:uuid="${page}">[[${page}]]</span>
    </div>
  </div>
</div>
<script src="../../../static/lib/layui/layui.js" type="text/javascript"></script>
<script src="../../../static/js/proDel.js" type="text/javascript"></script>

<!--  查找用户-->
<script>
  layui.use(['form', 'layer', "jquery"], function () {
    var form = layui.form,
            layer = layui.layer,
            $ = layui.jquery;

    //监听提交
    form.on('submit(search)', function (data) {
      var f = data.field;
      var username = f.username;
      var start = f.start;
      var end = f.end;
      if(username!="" || start!="" || end!="") {
        var find_data = {start: start,end: end, username: username}
        $.post({
          url: "/product/find",
          contentType: "application/json;charset=UTF-8",
          data: JSON.stringify(find_data),
          success: function (data) {
            $("#productList").html(data)
            $(".num[uuid=1]").addClass("current")
            $(".num[uuid=1]").siblings().removeClass("current")
          }
        })
      }
      return false;
    });
  });
</script>


<!--  换页-->
<script>
  $(".num[uuid=1]").addClass("current")
  $(".num").click(function () {
    var page = $(this).attr("uuid")
    $.post({
      url: "/product/page/"+page,
      contentType: "application/json;charset=UTF-8",
      success: function (data) {
        $("#productList").html(data)
      },
      async: false
    })
    $(this).addClass("current")
    $(this).siblings().removeClass("current")
  })
</script>
</body>

</html>